package com.hk.commons.eunms;

import java.text.MessageFormat;

public enum ExcelEnum implements Enums<String> {

    ANNOTATION_NOT_SPECIFIED("980000", "未指定明确的导入说明！"),

    FILE_TYPE_ERROR("980001", "上传文件类型错误，必须为.xlsx文件"),
    TITLE_LEN_ERROR("980002", "Excel标题列长度不匹配,请重新下载模版！"),
    TITLE_NAME_ERROR("980003", "第{0}列标题名错误，应为[{1}]！"),
    FILE_IMPORT_ERROR("980004", "导入失败！"),
    FILE_IMPORT_MSG("980005", "第{0}行{1}！")
    ;

    private String code;
    private String desc;

    private ExcelEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    @Override
    public String getDesc(Object... objs) {
        return MessageFormat.format(this.desc, objs);
    }

    public boolean equalsCode(String code) {
        return this.code.equals(code);
    }

    //通过value获取对应的枚举对象
    public static ExcelEnum getEnums(String value) {
        for (ExcelEnum code : ExcelEnum.values()) {
            if (code.getCode().equals(value)) {
                return code;
            }
        }
        return null;
    }
}
